
import { Context } from '@midwayjs/koa';
import { Catch, httpError } from '@midwayjs/core';
import { UnauthorizedError } from '@midwayjs/core/dist/error/http';

@Catch(httpError.UnauthorizedError)
export class UnauthorizedErrorFilter {
  async catch(err: UnauthorizedError, ctx: Context) {
    // token错误
    ctx.status = 401;
    return {
      code: 401,
      message: err.message,
    };
  }
}